
/*
 *  Copyright t lefering
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  These are the four essential freedoms with GNU GPL software:
 *  1: freedom to run the program, for any purpose
 *  2: freedom to study how the program works, and change it to make it do what you wish
 *  3: freedom to redistribute copies to help your Free Software friends
 *  4: freedom to distribute copies of your modified versions to your Free Software friends
 *   ,           ,
 *  /             \
 * ((__-^^-,-^^-__))
 * `-_---'  `---_-'
 *  `--|o`   'o|--'
 *      \  `  /
 *       ): :(
 *       :o_o:
 *        "-"
 */

#include "config.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "main.h"

/* This are current flex options which are defined:

NAME
       flex - the fast lexical analyser generator

SYNOPSIS
       flex [OPTIONS] [FILE]...

DESCRIPTION
       Generates programs that perform pattern-matching on text.

   Table Compression:
       -Ca, --align
              trade off larger tables for better memory alignment

       -Ce, --ecs
              construct equivalence classes

       -Cf    do not compress tables; use -f representation

       -CF    do not compress tables; use -F representation

       -Cm, --meta-ecs
              construct meta-equivalence classes

       -Cr, --read
              use read() instead of stdio for scanner input

       -f, --full
              generate fast, large scanner. Same as -Cfr

       -F, --fast
              use alternate table representation. Same as -CFr

       -Cem   default compression (same as --ecs --meta-ecs)

   Debugging:
       -d, --debug
              enable debug mode in scanner

       -b, --backup
              write backing-up information to lex.backup

       -p, --perf-report
              write performance report to stderr

       -s, --nodefault
              suppress default rule to ECHO unmatched text

       -T, --trace
              flex should run in trace mode

       -w, --nowarn
              do not generate warnings

       -v, --verbose
              write summary of scanner statistics to stdout

       --hex  use hexadecimal numbers instead of octal in debug outputs

FILES
       -o, --outfile=FILE
              specify output filename

       -S, --skel=FILE
              specify skeleton file

       -t, --stdout
              write scanner on stdout instead of lex.yy.c

       --yyclass=NAME
              name of C++ class

       --header-file=FILE
              create a C header file in addition to the scanner

       --tables-file[=FILE] write tables to FILE

       --backup-file=FILE
              write backing-up information to FILE

   Scanner behavior:
       -7, --7bit
              generate 7-bit scanner

       -8, --8bit
              generate 8-bit scanner

       -B, --batch
              generate batch scanner (opposite of -I)

       -i, --case-insensitive
              ignore case in patterns

       -l, --lex-compat
              maximal compatibility with original lex

       -X, --posix-compat
              maximal compatibility with POSIX lex

       -I, --interactive
              generate interactive scanner (opposite of -B)

       --yylineno
              track line count in yylineno

   Generated code:
       -+,  --c++
              generate C++ scanner class

       -Dmacro[=defn]
              #define macro defn  (default defn is '1')

       -L,  --noline
              suppress #line directives in scanner

       -P,  --prefix=STRING
              use STRING as prefix instead of "yy"

       -R,  --reentrant
              generate a reentrant C scanner

       --bison-bridge
              scanner for bison pure parser.

       --bison-locations
              include yylloc support.

       --stdinit
              initialize yyin/yyout to stdin/stdout

       --nounistd
              do not include <unistd.h>

       --noFUNCTION
              do not generate a particular FUNCTION

   Miscellaneous:
       -c     do-nothing POSIX option

       -n     do-nothing POSIX option

       -?

       -h, --help
              produce this help message

       -V, --version
              report flex version

*/

/* do options and open the files */
int options(int argc, char *argv[])
{
	if (argc == 1) {
		/* read spec from stdin */
		lexin = stdin;
		lexinname = "<stdin>";
		lexout = stdout;
		lexoutname = "<stdout>";
		lexlog = stderr;
		lexlogname = "<stderr>";
		return (0);
	}
	if (argv) {
	}

	/* todo handle options, set input/output names */

	/* for now, assume first arg is the filename */
	lexinname = dp_strdup(argv[1]);
	lexin = fopen(lexinname, "r");
	if (lexin == NULL) {
		printf("%s(): cannot open file `%s' for reading\n", __func__, lexinname);
		return (1);
	}

	lexoutname = "lex.yy.c";
	lexout = fopen(lexoutname, "w");
	if (lexout == NULL) {
		printf("%s(): cannot open file `%s' for writing\n", __func__, lexoutname);
		return (1);
	}

	lexlogname = "lex.yy.output";
	lexlog = fopen(lexlogname, "w");
	if (lexlog == NULL) {
		printf("%s(): cannot open file `%s' for writing\n", __func__, lexlogname);
		return (1);
	}

	return (0);
}

/* end */

/* vim:set tabstop=8 softtabstop=4 shiftwidth=4: */
